package servlet.manage.company;

import model.CompanyModel;
import net.sf.json.JSONArray;
import service.ICompanyService;
import service.impl.CompanyServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/CompanyDelete")
public class CompanyDelServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String ids =req.getParameter("id");
        Integer id = ids  ==null ? 0 : Integer.parseInt(ids);
        CompanyModel model=new CompanyModel();
        model.setId(id);

        ICompanyService service=new CompanyServiceImpl();
        int num=service.del(model);

        JSONArray jsonArray=JSONArray.fromObject(num);
        resp.getWriter().println(jsonArray);

    }
}
